import hashlib
import string
import time
def generate_random_string(user_id, project_id, length=8):
    seed = f"{user_id}-{project_id}"
    sha1_hash = hashlib.sha1(seed.encode()).hexdigest()
    random_str = sha1_hash[:length]
    return random_str
def generate_random_token(random_key, length=64):
    seed = f"{random_key}"
    sha1_hash = hashlib.sha256(seed.encode()).hexdigest()
    random_str = sha1_hash[:length]
    return random_str

def generate_random_from_username_password(username, password, length=64):
    seed = f"{username}-{password}"
    sha1_hash = hashlib.sha256(seed.encode()).hexdigest()
    random_str = sha1_hash[:length]
    return random_str

def generate_random_by_time(length = 32):
    timestamp = str(int(time.time()))
    random_str = hashlib.sha1(timestamp.encode()).hexdigest()[:length]
    return random_str

if __name__ == "__main__":
    user_id = "user123"
    project_id = "proj456"
    random_string = generate_random_string(user_id, project_id)
    print(random_string)